// 加密方法
export async function sha1(str: string) {
	const encoder = new TextEncoder();
	const data = encoder.encode(str);
	const hashBuffer = await crypto.subtle.digest('SHA-1', data);
	const hashArray = Array.from(new Uint8Array(hashBuffer));
	const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
	return hashHex;
}

export function extractTextFromHTML(html: string): string {
	// 使用正则表达式匹配 HTML 标签
	const regex = /<[^>]*>/g;
	// 用空字符串替换所有标签，提取文本
	const text = html.replace(regex, '');
	return text.trim();
}

